<%-- 
    Document   : main
    Created on : 23/09/2014, 22:20:02
    Author     : leoomoreira
--%>

<%@page import="cronos.application.Application"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../header.jsp" %>
<div id="title">Application Form</div>
<% if (request.getAttribute("message") != null) {%>
<br/>
<div id="message"><%=request.getAttribute("message").toString()%></div>
<% } %>
<br/>
<form action="ApplicationList" method="post">
    <div class="table">
        <div class="row">
            <div class="label">Id:</div>
            <div class="field"><input type="text" name="id" value="" /></div>
        </div>
        <div class="row">
            <div class="label">Name:</div>
            <div class="field"><input type="text" name="name" value="" /></div>
        </div>
    </div>
    <div>
        <button type="submit" class="search">
            <img src="images/search.png" title="Search" />Search
        </button>
    </div>
</form>
<%
    if (request.getAttribute("resultList") != null) {
%>
<br/>
<table class="list">
    <tr>
        <td class="caption">Id</td>
        <td class="caption">Name</td>
        <td class="twoopt">&nbsp;</td>
    </tr>
    <%
        List<Application> result = (List<Application>) request.getAttribute("resultList");
        for (int i = 0; result != null && i < result.size(); i++) {
            Application item = result.get(i);
    %>
    <tr class="<%=(i % 2 == 0 ? "even" : "odd")%>">
        <td><%= item.getId()%></td>
        <td><%= item.getName()%></td>
        <td>
            <a href="ApplicationShow?id=<%= item.getId()%>"><img src="images/edit.png" title="Edit" /></a>
            <a href="ApplicationDelete?id=<%= item.getId()%>"><img src="images/delete.png" title="Delete" /></a>
        </td>
    </tr>
    <%
        }
    %>
</table>
<%
    }
%>
<br/>
<button type="button" class="new" onclick="document.location = 'ApplicationNew'">
    <img src="images/new.png" />New
</button>
<%@include file="../footer.jsp" %>